#include <iostream>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
using namespace std;

void GuardQDWeb()
{
    pid_t pid=fork();
    if(pid>0)
    {
        exit(0);
    }
    int ret=setsid();
    if(ret<0)
    {
        perror("failed setsid");
        return;
    }
    chdir("/usr/local");
    close(STDIN_FILENO);
    close(STDOUT_FILENO);
    close(STDERR_FILENO);
    pid_t pid1=fork();
    if(pid1==0)
        execl("/usr/local/QDWeb/QDWeb","QDWeb",NULL);
    while(true)
    {
        wait(NULL);
        sleep(10);
        pid_t pid2=fork();
        if(pid2==0)
            execl("/usr/local/QDWeb/QDWeb","QDWeb",NULL);
    }
}

int main()
{
    GuardQDWeb();
    cout << "Hello World!" << endl;
    return 0;
}
